package com.tepth.busfix.adapter;

import android.content.Context;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.tepth.busfix.R;
import com.tepth.busfix.bean.reponse.Process;
import com.tepth.busfix.bean.reponse.TroubleContent;
import com.tepth.busfix.bean.reponse.TroubleType;

import java.util.List;

/**
 * Created by pc on 2017/3/17.
 */

public class JobContentAdapter extends BaseQuickAdapter<Process, BaseViewHolder> {

    private TroubleType mTroubleType;
    public JobContentAdapter(Context context, int layoutResId, List<Process> data) {
        super(layoutResId, data);
        mContext = context;
    }

    public void setTroubleType(TroubleType troubleType){
        mTroubleType = troubleType;
    }
    public TroubleType getTroubleType(){
        return mTroubleType;
    }
    @Override
    protected void convert(BaseViewHolder helper, Process item) {

        TroubleContent.Part part = item.getAccessory() == null ?
                item.getComponent() : item.getAccessory();
        String stringBuilder = item.getOperation().getName() +
                item.getUseCount() +
                part.getUnit() +
                item.getName();
        helper.setText(R.id.tv_des, stringBuilder);
        helper.setText(R.id.tv_percent, item.getPercentage() + "%");
        if(item.isChecked()){
            helper.setImageResource(R.id.iv_choose,R.drawable.icon_choose_green);
        }else{
            helper.setImageResource(R.id.iv_choose,R.drawable.icon_choose_blue);
        }
    }
}
